//
//  DownloadSetting.swift
//  YoruNeko
//
//  Created by Kotori on 2021/6/21.
//

import SwiftUI

struct DownloadSetting: View {
    @State var isDownAlert: Bool = false
    let currUserMgr = UserManager.currUserMgr
    
    var body: some View {
        List {
            Toggle("下载文件时弹出警告", isOn:$isDownAlert)
                .onChange(of: isDownAlert, perform: { isDownAlert in
                    currUserMgr.setDownloadAlert(alert: isDownAlert)
                })
        }
        .onAppear {
            isDownAlert = currUserMgr.getDownloadAlert()
        }
        .onDisappear(perform: {
            currUserMgr.commit()
        })
        
    }
    
    
    
}

struct DownloadSetting_Previews: PreviewProvider {
    static var previews: some View {
        DownloadSetting()
    }
}
